﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
namespace GameTank
{
    public class AIController : CharacterController
    {
        protected int AI = 0;
        protected int T2 = 10;
        protected int T3 = 0;
        protected Random random;

        public AIController()
        {
            random = new Random(this.GetHashCode());
            AI = 0;
            T2 = 10;
            T3 = random.Next(0, 4);
        }
        public AIController(Character ch)
        {
            random = new Random(this.GetHashCode());
            AI = 0;
            T2 = 10;
            T3 = random.Next(0, 4);
            Parent = ch;
        }

        public override void UpDatePosition(Microsoft.Xna.Framework.GameTime gameTime)
        {
            AI++;
            if (AI < T2)
            {
                switch (T3)
                {
                    case 0:
                        Parent.MoveUp();
                        break;
                    case 1:
                        Parent.MoveDown();
                        break;
                    case 2:
                        Parent.MoveLeft();
                        break;
                    default:
                        Parent.MoveRight();
                        break;
                }
                
            }
            else
            {
                AI = 0;
                T3 = random.Next(0, 4);
                if (T3 != 0)
                {
                    T2 = random.Next(30, 50);
                }
                else
                    T2 = random.Next(20, 40);
            }            
        }

        public override void UpDateFire(GameTime gameTime)
        {
            Parent.fire();
        }
    }
}
